package edu.xkd.slice;

import edu.xkd.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
import ohos.agp.components.Text;

public class MainAbilitySlice extends AbilitySlice {
    //下面单击事件要获取文本对象，而文本对象在下边方法中是局部变量，所以在方法外部要进行声明。
    Text text_01=null;
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);

        //编写业务逻辑
        //获取界面布局里的所有组件
        Text text_01=(Text) this.findComponentById(ResourceTable.Id_text_info);
        Button button_login=(Button)this.findComponentById(ResourceTable.Id_button_login);
        Button button_register=(Button)this.findComponentById(ResourceTable.Id_button_register);

        button_login.setClickedListener(this::clickedListenerButton_login);
        button_register.setClickedListener(this::clickedListenerButton_register);


    }

    private void clickedListenerButton_register(Component component) {
        text_01.setText("注册按钮点击！");
    }

    private void clickedListenerButton_login(Component component) {
        text_01.setText("登录按钮点击！");

    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
